<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商品详情页</title>
    <meta name="keywords" content="商品详情页"/>
    <meta name="description" content="商品详情页"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1, maximum-scale=1,minimum-scale=1, user-scalable=no">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="format-detection" content="telephone=no"/>

    <meta name="viewport" content="width=device-width,viewport-fit=cover">
    <link rel="stylesheet" type="text/css" th:href="@{/shoppingApi/css/public.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/shoppingApi/css/swiper.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/shoppingApi/css/detail.css}">
    <link th:href="@{/shoppingApi/css/weui.min.css}" rel="stylesheet">
    <link th:href="@{/shoppingApi/css/jquery-weui.min.css}" rel="stylesheet">
    <style type="text/css" rel="stylesheet">
        /*.swiper-wrapper .swiper-slide {*/
        /*padding-top:110%;position:relative;overflow:hidden;*/
        /*}*/
        /*.swiper-wrapper .swiper-slide img {*/
        /*width:100%;height:auto;position:absolute;top:0;left:0;*/
        /*}*/
        * {
            font-family: 'Microsoft Yahei';
        }
        .title {
            height: 45px;
            line-height: 45px;
            text-align: center;
            background-color: #f70029;
            color: #fff;
            font-size: 17px;
        }
        .tabs{
            overflow: hidden;
        }
        .tabs li {
            float: left;
            width: 50%;
            text-align: center;
            line-height: 55px;
            height: 55px;
        }
        .tabs li a {
            font-size: 15px;
            border-bottom: 2px solid #fff;
        }
        .tabs li.active a {
            color: #f70029;
            border-color: #f70029;
        }
        .triggerbuy {
            text-decoration: underline;
        }
        .borderb {
            border-bottom: 1px solid #f0f0f0;
        }
        .badge {
            display: inline-block;
            background-color: #ff5d16;
            height: 20px;
            line-height: 20px;
            border-radius: 10px;
            color: #fff;
            font-size: 12px;
            padding: 0 10px;
        }
        .countdown {
            /*position: absolute;*/
            /*bottom: 0;*/
            /*left: 0;*/
            width: 100%;
            height: 60px;
            z-index: 2;
            background-color: rgba(193,133,97,.7);
        }
        .countdown h3 {
            float: left;
            width: 60%;
            line-height: 60px;
            background-color: #ea1520;
            font-size: 18px;
            font-weight: bold;
            text-align: center;
            color: #fff;
            background: -webkit-linear-gradient(left, #F45111 , #F70029); /* Safari 5.1 - 6.0 */
            background: -o-linear-gradient(right, #F45111 , #F70029); /* Opera 11.1 - 12.0 */
            background: -moz-linear-gradient(right, #F45111 , #F70029); /* Firefox 3.6 - 15 */
            background: linear-gradient(to right, #F45111 , #F70029); /* 标准的语法（必须放在最后） */
        }
        .countdown .timer {
            text-align: center;
        }
        .countdown .timer p {
            /*color: #fff;*/
        }
        .countdown .timer p span {
            display: inline-block;
            padding: 0 2px;
            font-weight: bold;
        }
        .countdown .timer div span {
            display: inline-block;
            padding: 0 3px;
            margin: 0 2px;
            background-color: #101010;
            color: #fff;
        }
        .detail .goods_pics p {
            padding: 0 15px 10px;
            height: auto;
            line-height: 2;
            color: #666;
            text-align: justify;
        }
        .detail .goods_pics p:first-of-type {
            border-top: 1px solid #f0f0f0;
            padding-top: 10px;
        }



    </style>
</head>
<body>
<div class="main detail">
    <!--<h3 class="title">商品详情</h3>-->

    <div class="main_con c323232 bgfff">
        <div class="detail_con rela">
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <input type="hidden" name="productId" id="productId" value="491">
                    <div class="swiper-slide">
                        <!--<img class="w100" th:src="@{/shoppingApi/images/activity-01.jpg}">-->
                        <img class="w100" th:src="@{/shoppingApi/images/banner7.jpg}">

                    </div>
                </div>

                <div class="countdown">
                    <h3 class="">优惠活动限量抢购倒计时：</h3>
                    <div class="timer ft14" id="countdown">
                        <p class="pt5">距结束<span id="days">0</span>天</p>
                        <div><span id="hours">00</span>小时<span id="minutes">00</span>分<span id="seconds">00</span>秒</div>
                    </div>
                </div>
            </div>
            <div class="pl15 pr15 pt15 pb15">
                <p class="ft15 pb15 bold"><span class="badge">活动</span>【5.20超级福利，仅限7500个优惠名额】真爱凝胶，巨大优惠来袭
                    ！</p>
                <p class="ft14 pb15 borderb">
                    真爱凝胶，宫廷秘方，<span class="cf70029">8</span>大中药成分，<span class="cf70029">6</span>大核心优势，守护女性私处健康！原价<span class="cf70029">198元/盒（6支）</span>，活动优惠价<span class="cf70029">360元/3盒（18支）</span>。<br/>
                    <a class="cf70029 triggerbuy" href="javascript:;">【更多惊喜，限时抢购】</a>
                    <!--<a class="cf70029 " href="javascript:alert('即将开始，敬请期待！');">【更多惊喜，限时抢购】</a>-->
                </p>
                <p class="ft14 pt15">
                    <span class="c323232 bold">活动（限购）</span>：优惠名额仅仅只有<span class="cf70029">7500</span>个，名额抢完活动立即截止！
                    <!--<span class="cf70029">322元</span>的新品套装，赠送零售价-->
                    <!--<span class="cf70029">498元</span>贵州茅台集团蓝莓酒一件（每位体验者最多限购三套）。凡购买两盒芦荟泡泡染（每只单价-->
                    <!--<span class="cf70029">60元</span>），赠送零售价-->
                    <!--<span class="cf70029">78元</span>的芦荟去屑洗发水一瓶。-->
                </p>
            </div>
        </div>

        <div class="line"></div>
        <div class="goods_pics">
            <ul class="tabs">
                <li class="active"><a href="javascript:;">5.20活动</a></li>
                <li><a href="javascript:;">售后服务</a></li>
            </ul>
            <div class="tab-content">
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product_01.jpg}">
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product_02.jpg}">
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product_03.jpg}">
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product_04.jpg}">
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product_05.jpg}">
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product_06.jpg}">
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product_07.jpg}">
                <!--<img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product-8.jpg}">-->
                <!--<img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product-9.jpg}">-->
                <!--<img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product-10.jpg}">-->
                <!--<img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product-11.jpg}">-->
                <!--<img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product-12.jpg}">-->
                <!--<img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/activity-product-13.jpg}">-->
            </div>
            <div class="tab-content" style="display: none">
                <!--<p class="ft12">1、化妆护肤品及个人护理用品，因使用后造成商品不完好的，不适用七天无理由退货；如确属商品质量问题的，可办理退货，但申请退货时商品已过期或离过期不到3个月的情况除外(活动及清仓商品除外，例如：因商品保质期将到和外包装有损包括在内的所有活动清仓商品，我司在活动中已明确说明的，不予退换货。请顾客对此类商品谨慎购买!)，因个人喜好(气味，色泽、型号，外观)和个人肤质不同要求的退货除外；</p>-->
                <!--<p class="ft12">2、购买化妆护肤品及个人护理用品请当场验收，若商品有破损，渗漏，缺少，配送有误等问题，请当即与市场服务人员联系；</p>-->
                <!--<p class="ft12">3、我们保证商品的进货渠道和质量，如果客户在使用时对商品质量表示置疑，请出具书面鉴定，我们会按照国家法律规定予以处理。 </p>-->
                <!--<p class="ft12">4、如遇过敏问题产生退货需要提供正规医院的相关证明。</p>-->
                <img class="w100 db guige-zhutu" th:src="@{/shoppingApi/images/shouhui.jpg}">
            </div>
        </div>
        <div class="line"></div>
        <!--选择规格-->
        <div class="specifications c646464" style="display: none">
            <div class="specifications_con bgfff rela">
                <div class="flex pl15 pr15 pt20 pb20">
                <span class="img">
                    <!--规格主图-->
                    <img class="w100 db guiges-zhutu" th:src="@{/shoppingApi/images/guige-1.jpg}">
                    <!--<img class="w100 db guiges-zhutu" th:src="@{${map.productGuigePrice.imgurl}}"/>-->
                </span>

                    <div class="flex flex-col ft17 ml15">
                        <p class="mt20 cf70029" style="color: #f70029;">
                            <span><span class="ft13"></span>￥<label class="proprice bold">198.00</label></span><span
                                class="ml5 pro-Price">~￥<label class="bold">504.00</label></span>
                        </p>
                        <!--<p class="ft14 cf70029" style="color: #f70029;">（赚￥<label class="fenxiangzhuan" th:text="${#numbers.formatDecimal(map.fenXiangZhuan,1,2)}">12.5~￥26.8</label>）</p>-->
                        <p class="specifi ft14 c323232">
                            <span class="default">请选择规格</span>
                            <span class="gauge"></span>
                            <span class="size ml5"></span>
                        </p>
                    </div>
                </div>
                <!--规格显示开始-->
                <div class="gauge gauges ft12 overflow c323232">
                    <p class="ft14 pl15">规格</p>
                    <ul>
                        <li class="pro-guiges">
                            <span>
                                <label>5.20活动</label>
                            </span>
                            <input type="hidden" name="guigeId" class="guigeId" value="354">
                        </li>
                        <!--<li class="pro-guiges">-->
                            <!--<span>-->
                                <!--<label>套餐二：卫生巾（10包日用+6包夜用+4包护垫）/3箱</label>-->
                            <!--</span>-->
                            <!--<input type="hidden" name="guigeId" class="guigeId" value="353">-->
                        <!--</li>-->
                        <!--<li class="pro-guiges">-->
                            <!--<span>-->
                                <!--<label>防晒套餐&nbsp;+&nbsp;染发套餐</label>-->
                            <!--</span>-->
                            <!--<input type="hidden" name="guigeId" class="guigeId" value="317">-->
                        <!--</li>-->
                    </ul>
                </div>
                <div class="gauge size ft12 overflow c323232" style="display: none">
                    <p class="ft14 pl15">尺码 /其他</p>
                    <ul>
                        <li>
                            <span><label></label></span>
                        </li>
                        </li>
                        <li>
                            <span>中号</span>
                        </li>
                        <li>
                            <span>小号</span>
                        </li>
                    </ul>
                </div>


                <!--规格显示结束-->
                <p class="pl15 pr15 overflow num">
                    <span class="fl ft15 changtext">数量</span>
                    <span class="fr ft17 changenum">
                    <span class="minus">-</span>
                    <span>
                        <input type="number" value="1">
                    </span>
                    <span class="add">+</span>
                </span>
                </p>
                <p class="tip mt15 ftc ft10" style="display: none">
                    <span>请选择产品规格</span>
                </p>
                <p class="bottom_btn overflow ftc">
                    <!--<span class="addcart" style="background-color:#ff9900;color:#fff;">加入购物车</span>-->
                    <span class="buynow" style="width: 100%;">立即购买</span>
                </p>
                <img class="close abs" th:src="@{/shoppingApi/images/close2.png}">
            </div>
        </div>

        <!--分享赚-->
        <!--<div class="sharediv">-->
        <!--<div class="sharediv_con">-->
        <!--<p>赚3.45</p>-->
        <!--<p class="ftc">1.只要你的好友</p>-->
        <!--</div>-->
        <!--</div>-->

        <div class="fixedBox50">
            <ul class="fixed-bottom bottom detail-navbar flex-ac flex-pc ftc bgfff">
                <li class="it1 index ft12">
                    <a th:href="@{/wap/productIndex}" class="db">
                        <span class="dib">
                            <img th:src="@{/shoppingApi/images/detail_index.png}">
                        </span>
                        <p>首页</p>
                    </a>
                </li>
                <li class="lineh">
                    <span class="lineh1"></span>
                </li>
                <li class="it1 like ft12 product-collect">
                    <span class="dib">
                        <img th:src="@{/shoppingApi/images/detail_like.png}">
                    </span>
                    <p>收藏</p>
                </li>
                <li class="lineh">
                    <span class="lineh1"></span>
                </li>
                <li class="it1 cart ft12">
                    <a th:href="@{/wap/getCartList}" class="db">
                        <span class="dib rela">
                            <img th:src="@{/shoppingApi/images/detail_cart.png}">
                            <span class="num abs car-product-count"></span>
                        </span>
                        <p>购物车</p>
                    </a>
                </li>
                <li class="it1 buy">
                    <span class="ft17 cfff" id="share-buy">立即购买</span>
                </li>
                <li class="it1 sharebtn" id="sharebtn">

                    <p class="ft17 cfff" style="line-height: 49px;">分享</p>
                    <!--<p class="ft12 cfff">赚￥<label class="share-money" th:text="${#numbers.formatDecimal(map.fenXiangZhuan,1,2)}">0</label></p>-->
                </li>
            </ul>
        </div>
    </div>
</div>

<!--分享弹窗-->
<div id="sharePopup" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal share-layer">
        <!--<p class="ft17 cff0000 mb10 mt10 text-center" th:if="${map.userCommission!=0}">赚<label class="getmoney" th:text="${#numbers.formatDecimal(map.fenXiangZhuan,1,2)}"></label>-->
        <!--</p>-->
        <!--未登录-->
        <!--<p class="ft14 c323232 " style="padding: 15px 35px 10px 35px;"><span class="share-info" th:if="${map.userNo==null || map.userCommission==0}">1.注册获得代金券,为你购物省钱</span></p>-->
        <!--<p class="ft14 c323232" style="padding: 0 35px;"><span class="share-info" th:if="${map.userNo==null || map.userCommission==0}">2.分享给朋友，双方都获得代金券</span></p>-->
        <!--<p class="ft14 c323232 pl15 pr15" th:if="${map.userCommission!=0}"><span class="share-info" >只要你的好友通过你的链接购买此商品，你就能赚到至少</span><span class="cf70029 getmoney" th:text="${#numbers.formatDecimal(map.fenXiangZhuan,1,2)}"></span>元利润</p>-->


        <p class="flex mt20 mb20 flex-ac pl15 pr15">
            <span class="ml20 mr20 it1 lineh1"></span>
            <span class="ft14 c323232">分享到</span>
            <span class="ml20 mr20 it1 lineh1"></span>
        </p>
        <ul class="overflow ft14 c323232 ftc">
            <li id="shareMessage">
                <img class="wxhaoyou" th:src="@{/shoppingApi/images/share1.png}">
                <p class="mt10 ">微信好友</p>
            </li>
            <li id="shareTimeline">
                <img th:src="@{/shoppingApi/images/share2.png}">
                <p class="mt10">朋友圈</p>
            </li>
            <li id="shareImg">
                <img th:src="@{/shoppingApi/images/share4.png}">
                <p class="mt10">生成分享图</p>
            </li>
        </ul>
        <img class="close close-popup" th:src="@{/shoppingApi/images/close3.png}">
    </div>
</div>
<!--生成二维码-->
<div id="imageLayer" class="weui-gallery">
    <!--<img style="position:absolute;top:15%;left:15%;width:70%;" alt="">-->
    <div id="createImg" style="position:absolute;top:0;left:0;width:100%;height:100%;"></div>
    <!--<div class="weui-gallery__opr" id="saveImage" onclick="savePicture()">长按图片保存</div>-->
</div>
<input type="hidden" class="user-no-id" th:if="${map.userNo!=null}" th:value="${map.userNo.id}">
<!--<input type="hidden" class="test-no" th:if="${map.userNo!=null}" th:value="${map.userNo.userNo}">-->

<input type="hidden" class="user-no-id" th:if="${map.userNo==null}" value="">
<input type="hidden" class="finace-name" th:value="${'map.config.finacename3'}">
<input type="hidden" class="finace-count" th:value="${'map.config.giftDiscount'}">
<input type="hidden" class="new-user-commission" th:value="${'map.newUserCommission'}">
<input type="hidden" class="user-commission" th:value="${'map.userCommission'}">
<input type="hidden" id="activeSign" th:value="${'map.productGuigePrice.activeSign'}">

<!--快速导航-->
<div class="mini-mask"></div>
<div class="mini-btn"></div>
<div class="mini-nav">
    <ul>
        <li><a href="/">
            <h5>首页</h5>
        </a></li>
        <li><a href="/wap/selectProductYJAndRjClassfy">
            <h5>分类</h5>
        </a></li>
        <!--<li><a href="javascript:sharebtn()">-->
        <li><a href="javascript:sharebtn()">
            <h5>分享</h5>
        </a></li>
        <li><a href="/wap/openUserCenter">
            <h5>个人中心</h5>
        </a></li>
        <li><a href="javascript:alert('敬请期待...')">
            <h5>店铺</h5>
        </a></li>
        <li><a href="/wap/getCartList">
            <h5>购物车</h5>
        </a></li>
        <li><a href="javascript:alert('敬请期待...')">
            <h5>联系客服</h5>
        </a></li>
    </ul>
</div>
<div id="mini-popup" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal share-layer">
        <p class="flex mt20 mb20 flex-ac pl15 pr15">
            <span class="ml20 mr20 it1 lineh1"></span>
            <span class="ft14 c323232">分享到</span>
            <span class="ml20 mr20 it1 lineh1"></span>
        </p>
        <ul class="overflow ft14 c323232 ftc">
            <li id="miniShareMessage">
                <img class="wxhaoyou" th:src="@{/shoppingApi/images/share1.png}">
                <p class="mt10 ">微信好友</p>
            </li>
            <li id="miniShareTimeline">
                <img th:src="@{/shoppingApi/images/share2.png}">
                <p class="mt10">朋友圈</p>
            </li>
        </ul>
        <img class="close close-popup" th:src="@{/shoppingApi/images/close3.png}">
    </div>
</div>
<!--/快速导航-->
<style>
    .weui-toast--text {
        top: 80%;
    }

    .mini-btn {
        z-index: 10;
    }
</style>
</body>
<script type="text/javascript" th:src="@{/shoppingApi/js/jquery-3.3.1.min.js}"></script>
<!--<script type="application/javascript" th:src="@{/shoppingApi/js/common.js}"></script>-->
<!--<script type="application/javascript" th:src="@{/shoppingApi/js/swiper.min.js}"></script>-->
<script th:src="@{/shoppingApi/js/jquery-weui.min.js}"></script>
<!--<script type="text/javascript" th:src="@{/shoppingApi/js/H5Plus/common.js}"></script>-->
<script type="text/javascript" th:src="@{/shoppingApi/js/common.js}"></script>
<script type="text/javascript" th:src="@{/shoppingApi/js/plusShare.js}"></script>
<script th:src="@{/shoppingApi/js/mininav.js}"></script>
<script th:src="@{/shoppingApi/js/jquery.countdown.min.js}"></script>
<script>
    $(function () {
        loadSumW();
    });
    $('#countdown').countdown('2019/05/21 00:00:00', function(event) {
        // $(this).html(event.strftime('%-D day%!D %H:%M:%S'));
        $('#days').html(event.strftime('%-D'));
        $('#hours').html(event.strftime('%H'));
        $('#minutes').html(event.strftime('%M'));
        $('#seconds').html(event.strftime('%S'));
    });
    // var mySwiper = new Swiper('.swiper-container', {
    //     slidesPerView: 1,
    //     observer: true,
    //     observeParents: true,
    //     pagination: {
    //         el: '.swiper-pagination',
    //         type: 'fraction'
    //     }
    // })
    /*返回上一页*/
    $(".back").on('click', function () {
        window.history.back(-1);
    })
    /*改变输入框的值*/
    $(".specifications_con .num input[type='number']").change(function () {
        var num = $(this).val()
        //alert("数量：" + num)
    })

    /*数量加*/
    $(".specifications_con .num .changenum .add").on('click', function () {
        var newval = Number($(this).prev().find(":input[type='number']").val()) + 1;
        $(this).prev().find(":input[type='number']").val(newval);
    })

    /*数量减*/
    $(".specifications_con .num .changenum .minus").on('click', function () {
        if (Number($(this).next().find(":input[type='number']").val()) > 1) {
            var newval = Number($(this).next().find(":input[type='number']").val()) - 1;
            $(this).next().find(":input[type='number']").val(newval);
        }
    })

    /*选中规格*/
    var guigeId = 0;
    $(".pro-guiges").on('click', function () {
        guigeId = $(this).children('input').val();
        console.log("规格id=" + guigeId);
        $.ajax({
            type: "POST",
            url: "/wap/selectGuiGeById",
            data: {
                'guigeId': guigeId
            },

            success: function (result) {
                var imgGroup = result.imgGroups;
                var productGuiGe = result.productGuiGe;
                var productPrice = result.productPrice;
                var fenxiangZhuan = result.fenxiangZhuan;
                $.each(imgGroup, function (i) {
                    $('.imgGroup').attr("src", imgGroup[i]);//图组
                })
                // $('.guiges-zhutu').attr("src", productGuiGe.imgurl);//规格主图
                $('.pro-Price').remove();
                $('.proprice').html(productPrice.proPrice.toFixed(2));
                $('.fenxiangzhuan').html(fenxiangZhuan.toFixed(2));
            }
        })
    })

    // /*首页加入购物车*/
    // $(".bottom_btn .addcart").on('click', function () {
    //     var num = $(this).parents(".specifications_con").find(":input[type='number']").val();
    //     var productId = $('#productId').val();
    //     if ($.trim(guigeId) == 0) {
    //         // alert("请选择规格!");
    //         $.toast("请选择规格！", "text");
    //         return;
    //     }
    //     //检测用户是否登录
    //     $.ajax({
    //         url: '/wap/verUserLogin',
    //         success: function (result) {
    //             console.log(result.userNo);
    //             if (!isLogin(result.userNo)) {
    //                 // var currentURL = window.location.href;
    //                 // window.location.href = '/wap/openLoginPwd?currentURL=' + currentURL;
    //             } else {
    //                 addCart(productId, guigeId, num);
    //             }
    //         }
    //     })
    // })
    //
    // //加入购物车
    // function addCart(productId, guigeId, num) {
    //     $.ajax({
    //         url: "/wap/addCart?productId=" + productId + "&guigeId=" + guigeId + "&productCount=" + num,
    //         dataType: "json",
    //         success: function (result) {
    //             if (result.data > 0) {
    //                 // window.location="/wap/getCartList";
    //                 $.toast("加入购物车成功！", "text");
    //                 window.location.reload();
    //             } else {
    //                 $.toast("添加购物车失败!", 'cancel');
    //             }
    //         }
    //     })
    // }
    //
    /*规格立即购买*/

    $(".bottom_btn .buynow").on('click', function () {
        var num = $(this).parents(".specifications_con").find(":input[type='number']").val();
        var productId = $.trim($('#productId').val());
        //选择规格
        if ($.trim(guigeId) == 0) {
            // alert("请选择规格!");
            $.toast("请选择规格！", "text");
            return;
        }
        if(guigeId==505){
            if(num>1){
                $.toast("当前产品单次限购数量1!",1000, function() {
                });
                return;
            }
        }
        if (productId <= 0) {
            $.toast("请选择要购买的商品！", "text");
            return;
        } else {
            //检测用户是否登录
            $.ajax({
                url: '/wap/verUserLogin',
                async: false,
                success: function (result) {
                    if (!isLogin(result.userNo)) {

                        // var currentURL = window.location.href;
                        // window.location.href = '/wap/openLoginPwd?currentURL=' + currentURL;
                    } else {
                        //跳转到立即购买页面
                        window.location.href = "/wap/directAddOrder?productId=" + productId + "&guigeId=" + guigeId + "&productCount=" + num;
                    }
                }
            })

        }
    })

    /*规格页关闭*/
    $(".specifications_con .close").on('click', function () {
        $(".specifications").fadeToggle();
    })
    var count=0;
    var limit=0;
    var limitNumber=0;
    function loadSumW() {
        $.ajax({
            url: "/wActivitySum",
            dataType: "json",
            async:false,
            success: function (data) {
                //alert(data.count+"---"+data.data);
                if (data.code == "0") {
                    count=data.count;
                    limit=data.data;
                    limitNumber=limit;
                    if(count>=limit){
                        $('.buy').find('#share-buy').html("活动结束");
                    }
                }

            }
        });
        return count;
    }

    /*首页立即购买*/
    $(".fixedBox50 .buy").on('click', function () {
        if(count>=limit){
            $('.buy').find('#share-buy').html("活动结束");
            return;
        }
            //alert("活动暂时无法下单，请稍后！");
             $(".specifications").fadeToggle();
    });

    $(".triggerbuy").on('click', function () {
        if(count>=limit){
            $('.buy').find('#share-buy').html("活动结束");
            return;
        }
        //alert("活动暂时无法下单，请稍后！");
         $(".specifications").fadeToggle();

    });


    /*选择规格*/
    $(".specifications_con .gauges ul li").on('click', function () {
        if (!$(this).hasClass("active")) {
            $(this).siblings().removeClass("active");
            $(this).addClass("active");
            var text = $(this).find("span").text();
            $(".specifi span.default").text('');
            $(".specifi span.gauge").text(text);
            $(".tip").fadeOut();
        }
    })


    /*选择尺码*/
    $(".specifications_con .size ul li").on('click', function () {
        if (!$(this).hasClass("active")) {
            $(this).siblings().removeClass("active");
            $(this).addClass("active");
            var text = $(this).find("span").text();
            $(".specifi span.default").text('');
            $(".specifi span.size").text(text);
            $(".tip").fadeOut();
        }
    })

    $('.look-all').on('click', function () {
        alert("暂时无更多评论！");
        var productId = $('.commentProductId').val();
    })


    /*获取购物车总数*/
    function getCartListCount() {
        $.ajax({
            url: '/wap/getCartProCountByUserId',
            success: function (result) {
                console.log(result);
                if (result == 0) {
                    $('.car-product-count').html('0');
                } else {
                    $('.car-product-count').html(result);
                }
            }
        })
    }

    $(function () {
        getCartListCount();

        // 切换产品详细
        $('.tabs li').each(function (index, el) {
            $(this).on('click', function () {
                $(this).addClass('active').siblings().removeClass('active');
                $('.tab-content').eq(index).show().siblings('.tab-content').hide();
            })
        })

        // 切换规格图
        var guigeImgs = ['/shoppingApi/images/guige-1.jpg','/shoppingApi/images/guige-2.jpg','/shoppingApi/images/guige-3.jpg'];
        $('.gauges ul li').each(function (index, el) {
            $(this).on('click', function() {
                $('.guiges-zhutu').attr("src", guigeImgs[index]);//规格主图
            });
        });
    })

    // 分享赚
    var userNoId = '';
    var proId = '';
    var proTitle = '';
    var proImg = '';
    var qrImgUrl = '';
    $.toast.prototype.defaults.duration = 1000;
    $(function () {
        if (isApp()) {
            $('#saveImage').text('保存到手机相册');
        } else {
            $('.app-download').show();
            $('.app-download .close').click(function () {
                $('.app-download').hide();
            });
        }
        // if(navigator.userAgent.indexOf("Html5Plus") > -1){
        //     userNoId = plus.storage.getItem('userNoId') || '';
        // } else {
        //     userNoId = localStorage.getItem('userNoId') || '';
        // }
        userNoId = $('.user-no-id').val() || location.href.split('usernoid=')[1] || '';
        // 打开分享操作面板
        $('#sharebtn').on('click', function () {
            // alert("活动即将开始，敬请期待！");
            if (!userNoId) {
                $.toast('登陆后才能分享！', 'text');
                return;
            }
            proId = $('#productId').val();
            proImg = location.host + $('.imgGroup:first').attr('src');
            proTitle = "活动【5.20超级福利，仅限7500个优惠名额】真爱凝胶，巨大优惠来袭！";
            $('.getmoney').text($('.share-money').text());
            $('#sharePopup').popup();
        });
      //  分享朋友按钮
        $('#shareMessage').on('click', function () {
            if (!isLogin(userNoId, true, '登陆后才能分享')) return;
            if (isApp()) {
                // downloadEl.style.display = "none";//隐藏下载banner
                //分享内容，开发者可自定义
                var message = {
                    title: proTitle, //应用名字
                    content: "",
                    href: location.host+ "/wap/activity?productId=" + proId + "&userNoId=" + userNoId, //分享出去后，点击跳转地址
                    thumbs: [proImg] //分享缩略图
                }
                //调起分享
                shareMessage(message, function (res) {
                    //分享回调函数
                    if (res) {
                        plus.nativeUI.toast("分享成功");
                    } else {
                        plus.nativeUI.toast("分享失败");
                    }
                    $.closePopup();
                })

            } else {
                $.toast('请生成分享图', 'forbidden');
            }
        });
        // 分享朋友圈按钮
        $('#shareTimeline').on('click', function () {
            if (!isLogin(userNoId, true, '登陆后才能分享')) return;
            if (isApp()) {
                // downloadEl.style.display = "none";//隐藏下载banner
                //分享内容，开发者可自定义
                var message = {
                    title: proTitle, //应用名字
                    content: "",
                    href: location.host+ "/wap/activity?productId=" + proId + "&userNoId=" + userNoId, //分享出去后，点击跳转地址
                    thumbs: [proImg] //分享缩略图
                }
                //调起分享
                shareTimeline(message, function (res) {
                    //分享回调函数
                    if (res) {
                        plus.nativeUI.toast("分享成功");
                    } else {
                        plus.nativeUI.toast("分享失败");
                    }
                    $.closePopup();
                })

            } else {
                $.toast('请生成分享图', 'forbidden');
            }
        });

        // 生成二位码按钮
        $('#shareImg').on('click', function () {
            if (!isLogin(userNoId, true, '登陆后才能生成分享图')) return;
            qrImg();
        });

      //  保存图片后关闭浮层
        $('#saveImage').on('click', function (e) {
            if (isApp()) {
                    plus.gallery.save(qrImgUrl, function () {
                        plus.nativeUI.toast("保存成功");
                    }, function () {
                        plus.nativeUI.toast("保存失败");
                    });
            }
            $('#imageLayer').hide();
        });


   //     点击遮罩关闭浮层
        $('#imageLayer').on('click', function (e) {
            // var target = $(e.target);
            // if (target.is('#imageLayer')) {
            //     target.hide();
            // }
            $(this).hide();
        });
    });

    // 生成分享图片
    function qrImg() {
        $.showLoading('图片生成中');
        $.closePopup();
        $.ajax({
            type: 'get',
            url: '/wap/getEnCode?productId=' + proId,
            success: function (res) {
                if (res.ewmURL) {
                    console.log(res.ewmURL)
                    console.log(JSON.stringify(res.ewmURL))
                    if (res.loginInfo == 'unlogin') {
                        $.toast('请去个人中心登录！', 'cancel');
                        return;
                    }
                    $.hideLoading();
                    // 图片生成成功，打开浮层，关闭分享弹窗
                    imageLayer(res.ewmURL);
                } else {
                    setTimeout(function () {
                        $.hideLoading();
                        $.toast('图片生成失败', 'cancel');
                    }, 6000);
                }
            },
            error: function (err) {
                $.toast('图片生成失败', 'cancel');
                $.hideLoading();
            }
        });
    }

    // 图片浮层
    function imageLayer(img) {
        var layout = $('#imageLayer');
        qrImgUrl = location.host + img;
        // layout.find('img').attr('src', img);
        $('#createImg').css({
            background: 'url("'+img+'") center no-repeat rgba(0,0,0,0.8)',
            backgroundSize: 'contain'
        })
        layout.show();
        $.toast('请截图保存', 'text');
    }

    // 规则提示浮层
    // function openTips(index) {
    //     $('#tipsPopup').addClass('custom-dialog--visible');
    // }
    //
    // function closetips() {
    //     $('#tipsPopup').removeClass('custom-dialog--visible');
    // }


    //收场商品
    $('.product-collect').on('click', function () {
        // productCollect();
        location.href = '/wap/productcollect';
    })

    function productCollect() {
        var productId = $('#productId').val();
        var minPrice = $('.minPrice').html();
        $.ajax({
            async: false,
            url: '/wap/proAddCollect?productId=' + productId + "&productPrice=" + minPrice,
            success: function (res) {
                //console.log(res);
                if (res.loginMsg != null) {
                    if (res.msg == '1') {
                        $.toast('已收藏！');
                    } else {
                        $.toast('收藏数据有误！', 'cancel');
                    }
                } else {
                    window.location.href = '/wap/openLoginPwd';
                }
            }
        })
    }

    //根据登录情况、等级显示商城价格
    showProPriceByLogin();

    function showProPriceByLogin() {
        var userNoId = $('.user-no-id').val();
        var newuserCommission = $('.new-user-commission').val();
        var userCommission = $('.user-commission').val();
        var finaceCash = $.trim(parseFloat($('.finace-cash').val()).toFixed(2));
        if (!userNoId) {
            $('.rank-show-price').hide();
            $('.share-money').html($('.finace-count').val());
        } else {
            if (userCommission <= newuserCommission) {
                $('.rank-show-price').html('可用代金券:<span class="ft15 cf70029">￥</span><span class="cf70029 ft17 bold">' + finaceCash + '</span>');
                $('.share-money').html($('.finace-count').val());
            }
        }
    }

    // app诊断
    function isApp () {
        return navigator.userAgent.indexOf("Html5Plus") > -1;
    }

    var r = null;
    // 扩展API加载完毕，现在可以正常调用扩展API
    if (window.plus) {
        onPlusReady();
    } else {
        document.addEventListener( "plusready", onPlusReady, false );
    }
    function onPlusReady() {
        r = plus.gallery
    }
    // 保存图片到相册中
    function savePicture() {
        // plus.gallery.save( "_doc/a.jpg", function () {
        //     alert( "保存图片到相册成功" );
        // } );
        if (isApp()) {
            // var src = $('#imageLayer').find('img').attr('src');
            // plus.gallery.save('http://www.ycsqd.com/1552190271520.jpg', function () {
            r.save(qrImgUrl, function () {
                plus.nativeUI.toast("保存成功");
            }, function () {
                plus.nativeUI.toast("保存失败"+qrImgUrl);
            });
        }
        $('#imageLayer').hide();
    }


    //getCodeTimer();
    function getCodeTimer () {
        var codeTimer = setInterval(function () {
            count=loadSumW();
            if (count >= limitNumber) {
                clearInterval(codeTimer);
            }
        }, 1000*60);

    }

</script>
</html>